package com.hzy.fivepalace.admin.controller;

import com.hzy.fivepalace.admin.annotation.Login;
import com.hzy.fivepalace.admin.controller.base.BaseController;
import com.hzy.fivepalace.common.util.ResponseUtil;
import com.hzy.fivepalace.db.domain.DtsGoodsSecurity;
import com.hzy.fivepalace.db.service.DtsGoodsSecurityService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.constraints.NotNull;

/**
 * 商品服务
 *
 * @author gejian
 */
@RestController
@RequestMapping("/admin/goodsSecurity")
@Api(tags = "商品保障服务")
@ResponseBody
@Login
public class AdminGoodsSecurityController extends BaseController {

    @Resource
    private DtsGoodsSecurityService goodsSecurityService;

    /**
     * 列表（不分页）
     *
     * @return
     */
    @PostMapping("/list")
    @ApiOperation(value = "列表(不分页)")
    public Object getList() {


        return ResponseUtil.ok(goodsSecurityService.selectList());
    }

    /**
     * 删除商品保障
     *
     * @param id
     * @return
     */
    @PostMapping("/del")
    @ApiOperation(value = "删除")
    public Object delGoodsSecurity(@ApiParam(value = "主键") @RequestParam @NotNull Integer id) {


        return goodsSecurityService.delGoodsSecurity(id);
    }

    /**
     * 新增商品保障
     *
     * @param goodsSecurity
     * @return
     */
    @PostMapping("/add")
    @ApiOperation(value = "新增")
    public Object addGoodsSecurity(DtsGoodsSecurity goodsSecurity) {


        return goodsSecurityService.addGoodsSecurity(goodsSecurity, getAdminId());
    }

    /**
     * 修改商品保障
     *
     * @param goodsSecurity
     * @return
     */
    @PostMapping("/upd")
    @ApiOperation(value = "修改")
    public Object updGoodsSecurity(DtsGoodsSecurity goodsSecurity) {


        return goodsSecurityService.updGoodsSecurity(goodsSecurity);
    }

}
